package com.easygem.controller.business;

import com.easygem.business.service.BgCircuitService;
import com.easygem.common.model.business.BgClient;
import com.easygem.common.model.business.Circuit;
import com.easygem.common.response.ResponseBean;
import com.easygem.common.vo.system.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 李鹏志
 * @version 1.0
 * @Description TODO
 * @date 2025/2/27 19:09
 */
@Api(tags = "线路类型")
@Controller
@Validated
@CrossOrigin
@RequestMapping("/bgCircuit")
public class BgCircuitController {
    @Autowired
    private BgCircuitService circuitService;

    @ApiOperation(value = "线路类型列表", notes = "模糊查询线路类型列表")
    @GetMapping("/findList")
    @ResponseBody
    public ResponseBean<List<Circuit>>  getCircuitList(){
        List<Circuit> circuitList = circuitService.getCircuitAll();
        return ResponseBean.success(circuitList);
    }

    @ApiOperation(value = "修改线路类型", notes = "根据id查询线路类型列表")
    @GetMapping("/getCircuitById/{id}")
    @RequiresPermissions({"circuit:update"})
    @ResponseBody
    public ResponseBean<Circuit> getCircuitById(@PathVariable Long id){
        Circuit circuit = circuitService.getCircuitById(id);
        return ResponseBean.success(circuit);
    }

    @ApiOperation(value = "修改线路类型", notes = "根据id修改线路类型")
    @PostMapping("/updateCircuit")
    @ResponseBody
    public ResponseBean updateCircuit(@RequestBody Circuit circuit){
        int i = circuitService.updateCircuit(circuit);
        if (i>0){
            return ResponseBean.success("true");
        }
        return ResponseBean.success("false");
    }

    @ApiOperation(value = "添加线路类型", notes = "添加线路类型")
    @PostMapping("/addCircuit")
    @RequiresPermissions({"circuit:add"})
    @ResponseBody
    public ResponseBean addCircuit(@RequestBody Circuit circuit){
        int i = circuitService.addCircuit(circuit);
        if (i>0){
            return ResponseBean.success("true");
        }
        return ResponseBean.success("false");
    }
}
